package com.lvtu.monitor.utils.mail;


import java.io.IOException;
import java.util.Properties;
/**
 * 
 * @author Administrator
 *
 */
public class MailConfig {
	private static volatile MailConfig instance = null;
	
	private static Properties properties;
	
	private MailConfig() {
		init();
	}

	/**
	 * 初始化配置文件 
	 */
	private void init() {
		try {
			properties = new Properties();
			properties.load(this.getClass().getResourceAsStream("/mail.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 加载配置文件
	 * @return
	 */
	public static MailConfig getInstance() {
		if (instance == null) {
			synchronized (MailConfig.class) {
				if (instance == null) {
					instance = new MailConfig();
				}
			}
		}
		return instance;
	}
	
	/**
	 * 读取配置
	 * @param key
	 * @return
	 */
	public String getProperty(String key) {
		return properties.getProperty(key);
	}
	
	public static void main(String[] args) {
		System.out.println(MailConfig.getInstance().getProperty("mail.host"));
	}
}
